package com.zzptc.syl.viewpager;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
import com.github.mikephil.charting.data.PieEntry;

import java.util.ArrayList;
import java.util.List;

public class ThreeFragment extends Fragment {

    private List<PieEntry> data = new ArrayList<>();
    public ThreeFragment() {
        // Required empty public constructor
    }

    public static ThreeFragment newInstance(String param1, String param2) {
        ThreeFragment fragment = new ThreeFragment();
        Bundle args = new Bundle();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        //绑定视图
        View view = inflater.inflate(R.layout.fragment_three, container, false);
        //实例化pieChart
        PieChart pieChart = view.findViewById(R.id.pieChart);
        data.add(new PieEntry(2,"男"));
        data.add(new PieEntry(3,"女"));
        //设置数据
        PieDataSet pieDataSet = new PieDataSet(data,"");
        //建立数组
        PieData pieData = new PieData(pieDataSet);
        //将数组添加至控件中
        pieChart.setData(pieData);
        //返回视图
        return view;
    }
}